package com.personal.portal.common.config;

import cn.hutool.core.date.DateUtil;
import com.mybatisflex.annotation.InsertListener;
import com.personal.portal.common.entity.BaseEntity;
import com.personal.portal.common.entity.StatusEnum;

public class MybatisInsertListener implements InsertListener {
    @Override
    public void onInsert(Object o) {
        if (o instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) o;
            baseEntity.setCreateBy("zhanghui");
            baseEntity.setCreateTime(DateUtil.now());
            baseEntity.setUpdateBy("zhanghui");
            baseEntity.setUpdateTime(DateUtil.now());
            baseEntity.setStatus(StatusEnum.ENABLED.getCode());
        }
    }
}
